package cn.wolfcode.crm.config;

import cn.wolfcode.crm.web.interceptor.LoginInterceptor;
import cn.wolfcode.crm.web.interceptor.PermissionInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class MvcJavaConfig implements WebMvcConfigurer {

    /*注册拦截器*/
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private PermissionInterceptor permissionInterceptor;

    public void addInterceptor(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**").//拦截的规则
                excludePathPatterns("/loginUser.do", "login.html", "/css/**", "/js/**");//排除拦截的规则
        registry.addInterceptor(permissionInterceptor)
                .addPathPatterns("/**") //拦截的规则
                .excludePathPatterns("/loginUser.do");//排除拦截的规则


    }
}
